#ifndef LIB_UTILS_OAUTHCLIENT_P_H
#define LIB_UTILS_OAUTHCLIENT_P_H

#include "OAuthClient.h"
#include <QString>
class QNetworkReply;

namespace TWUtils
{
	class OAuthClientPrivate : public QObject
	{
		Q_OBJECT
		public:
			OAuthClientPrivate(const char* consumer_key,const char* consumer_secret,OAuthClient*);
			~OAuthClientPrivate(){}

			void retrieveRequestToken(const QString& requestURL,const QOAuth::ParamMap* map);
			void retrieveAccessToken(const QString& accessTokenUrl,const QOAuth::ParamMap& map);

			QByteArray createParametersString(const QString&			requestUrl,
											  QOAuth::HttpMethod	httpMethod,
											  const QOAuth::ParamMap&	params,
											  QOAuth::ParsingMode	mode);
		private:
			const static QByteArray OAuthVersion;
			const static QByteArray ParamToken;
			const static QByteArray ParamTokenSecret;
			const static QByteArray ParamConsumerKey;
			const static QByteArray ParamNonce;
			const static QByteArray ParamSignature;
			const static QByteArray ParamSignatureMethod;
			const static QByteArray ParamTimestamp;
			const static QByteArray ParamVersion;

			const QByteArray consumer_key;
			const QByteArray consumer_secret;

			OAuthClient* m_pImpl;

			bool inclusiveHeader;

			bool hasValidAccessToken;
			bool isReceivingAccessToken;

			QByteArray oauth_token;
			QByteArray oauth_token_secret;

			QString authorizeAccessTokenUrl;

			QString m_additionalParams;
			QNetworkAccessManager* manager;

			QByteArray createSignature(const QString& requestUrl,
									   QOAuth::HttpMethod httpMethod,
									   const QByteArray& token,
									   const QByteArray& tokenSecret,
									   QOAuth::ParamMap* params);
			QByteArray createPlaintextSignature(const QByteArray& tokenSecret);
			QByteArray paramsToString(const QOAuth::ParamMap& parameters,QOAuth::ParsingMode mode);
		public slots:
			void onTokenReceived(QNetworkReply*);
		friend class OAuthClient;
	};
}
#endif // LIB_UTILS_OAUTHCLIENT_P_H
